home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / cuj1008.zip / 1008133A < prev    next >
Text File  |  1992-06-09  |  1KB  |  36 lines

  1.  
  2.    #define MAX_STRINGS 100
  3.    #define SIZE_STRING 100
  4.    #define SIZE_ALL_STRINGS 5000
  5.    char *get_string(int index)
  6.        {
  7.        static char *string[MAX_STRINGS];
  8.        static char *string_buffer;
  9.        static int initialized;
  10.        int size;
  11.        int total_size = 0;
  12.        int count;
  13.        FILE *string_file;
  14.  
  15.        if (!initialized)
  16.            {
  17.            string_buffer = calloc(SIZE_ALL_STRINGS, 1);
  18.            string_file = fopen("string.fil","r");
  19.            /* Read the file into string_buffer */
  20.            string[0] = string_buffer;
  21.            size = 0;
  22.            for (count = 0; count < MAX_STRINGS; count++)
  23.                {
  24.                fgets(string_file, string[count], SIZE_STRING);
  25.                size = strlen(string[count]);
  26.                string[count][size - 1] = '\0';    
  27.                size--;
  28.                total_size += size;
  29.                string[count+1] = string_buffer + total_size;
  30.                }       
  31.            initialized = 1;
  32.            }
  33.        return string[index];
  34.        }    
  35.  
  36.